<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
include_once("$board_skin_path/config.php");
//************************************************************
//
// 스킨명 : 카멜레온 간이몰 스킨
// 버  젼 : 2006-03-16일짜 버젼
// 제작자 : ⓒⓒⓒ (Soonho Choi) http://cm-builder.com
// MSN    : oldccc@oldccc.com
// 
// 저작권 : 이 주석 부분을 훼손하지 상태에서 수정및 사용이 자유롭습니다.
//
//************************************************************
//
// 스킨명 : 간이몰 스킨 1v
// 수  정 : 2006-07-29일
// 수정자 : 스펙트럼 (toptalent) http://spectrum-enter.com/YBH/
// E-mail : top-talent@hanmail.net
// 
// 저작권 : 이 주석 부분을 훼손하지않은 상태에서 수정및 사용이 자유롭습니다.
//
//************************************************************

$icon_new = $icon_good = $icon_hit = $icon_point = $icon_aa = $icon_sellout ="";
if($view[wr_type1]) $icon_new = "<img src='$board_skin_path/img/icon_new.gif' align=absmiddle> ";
if($view[wr_type2]) $icon_good = "<img src='$board_skin_path/img/icon_good.gif' align=absmiddle> ";
if($view[wr_type3]) $icon_hit = "<img src='$board_skin_path/img/icon_hit.gif' align=absmiddle> ";
if($view[wr_type4]) $icon_point = "<img src='$board_skin_path/img/icon_point.gif' align=absmiddle> ";
if($view[wr_type5]) $icon_aa = "<img src='$board_skin_path/img/icon_24_02.gif' align=absmiddle> ";
if($view[wr_type6]) $icon_sellout = "<img src='$board_skin_path/img/icon_sellout.gif' align=absmiddle>";
?>

<script type="text/javascript" src="<?=$board_skin_path?>/thumbnailviewer2.js" defer="defer">
/***********************************************
* Image Thumbnail Viewer II script-  Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/
</script>
<script language="javascript" src="<?=$board_skin_path?>/money.js"></script>

<!-- 게시글 보기 시작 -->
<table width="<?=$width?>" align="center" cellpadding="0" cellspacing="0">
<tr>
	<td>

	<div style="clear:both; height:30px;">
		<div style="float:left; margin-top:6px;">
		<img src="<?=$board_skin_path?>/img/icon_date.gif" align=absmiddle>
		<span style="color:#888888;">등록일 : <?=date("y-m-d H:i", strtotime($view[wr_datetime]))?></span>
		</div>

		<!-- 링크 버튼 -->
		<div style="float:right;">
		<? 
		ob_start(); 
		?>
		<? if ($copy_href) { echo "<a href=\"$copy_href\"><img src='$board_skin_path/img/btn_copy.gif' border='0' align='absmiddle'></a> "; } ?>
		<? if ($move_href) { echo "<a href=\"$move_href\"><img src='$board_skin_path/img/btn_move.gif' border='0' align='absmiddle'></a> "; } ?>

		<? if ($search_href) { echo "<a href=\"$search_href\"><img src='$board_skin_path/img/btn_list_search.gif' border='0' align='absmiddle'></a> "; } ?>
		<? echo "<a href=\"$list_href\"><img src='$board_skin_path/img/btn_list.gif' border='0' align='absmiddle'></a> "; ?>
		<? if ($update_href) { echo "<a href=\"$update_href\"><img src='$board_skin_path/img/btn_modify.gif' border='0' align='absmiddle'></a> "; } ?>
		<? if ($delete_href) { echo "<a href=\"$delete_href\"><img src='$board_skin_path/img/btn_delete.gif' border='0' align='absmiddle'></a> "; } ?>
		<? if ($reply_href) { echo "<a href=\"$reply_href\"><img src='$board_skin_path/img/btn_reply.gif' border='0' align='absmiddle'></a> "; } ?>
		<? if ($write_href) { echo "<a href=\"$write_href\"><img src='$board_skin_path/img/btn_write.gif' border='0' align='absmiddle'></a> "; } ?>
		<?
		$link_buttons = ob_get_contents();
		ob_end_flush();
		?>
		</div>
	</div>
	
	<table width="100%" cellpadding=0 cellspacing=2 border=0 bgcolor="#EEEEEE">
	<tr>
		<td>
		<table cellpadding="0" cellspacing="0" border="0" width="100%" bgcolor="#FFFFFF">
		<tr><td height="10"></td></tr>
		<tr>
			<td valign=top>

			<table cellpadding=0 cellspacing=0 border=0 align="center">
			<form name=cart method="POST" action="javascript:cart_submit(document.cart);" autocomplete="off">
			<input type=hidden name=bo_table value='<?=$bo_table?>'>
			<input type=hidden name=wr_subject value='<?=$view['subject']?>'>
			<input type=hidden name=ca_name value='<?=$view['ca_name']?>'>
			<input type=hidden name=wr_id value='<?=$wr_id?>'>
			<input type=hidden name=sw_direct>
			<tr>
				<td width="270">

				<table cellpadding=0 cellspacing=1 border=0>
				<tr>
					<td>
					<table cellpadding=0 cellspacing=0 border=0>
					<tr>
						<td>
						<?
							$view_type = "horizontal";
							if($view_type == "vertical") {
								include $board_skin_path."/vertical_view.php";
							} else {
								include $board_skin_path."/horizontal_view.php";
							}
						?>
						</td>
					</tr>
					<tr>
						<td height="50" align="center"><a href='#' onclick="javascript:window.open('<?=$board_skin_path?>/view_open.php?bo_table=<?=$bo_table?>&wr_id=<?=$wr_id?>','view_open','width=650,height=560,top=50,left=50,scrollbars=yes,resizable=yes')"><img src="<?=$board_skin_path?>/img/icon_open.gif" alt='큰이미지 보기' border="0"></a></td>
					</tr>
					</table>
					</td>
				</tr>
				</table>
				</td>
				<td valign=top>
		
				<table border="0" width="100%" cellpadding=5 cellspacing=0>
				<tr bgcolor="#FFFFFF">
					<td colspan="4"><FONT STYLE="color:#CC00FF;font-size:16;font-style:normal;font-weight:"><b><?=$view[subject]?></b></font>&nbsp;&nbsp;<?=$icon_new?><?=$icon_good?><?=$icon_hit?><?=$icon_point?><?=$icon_aa?><?=$icon_sellout?></td>
				</tr>
				<tr><td colspan=4 height=5></td></tr>
				<tr><td colspan=4 height=1 bgcolor=#e7e7e7></td></tr>
				<tr><td colspan=4 height=5></td></tr>
				<tr>
					<td width="3" height=20><center><img src="<?=$board_skin_path?>/img/bul_07.gif"></td>
					<td width="100">상품코드</td>
					<td width="2">:</td>
					<td width="200"><font color="#0000ff"><?=$view[wr_10]?></font></td>
				</tr>
				<tr>
					<td width="3" height=20><center><img src="<?=$board_skin_path?>/img/bul_07.gif"></td>
					<td width="100">판매가</td>
					<td width="2">:</td>
					<td width="200"><font color="#FF0066"><b><?=number_format($view[wr_price])?>원</b></font></td>
				</tr>
				<?
				$cn=0;
				for($i=1;$i<5;$i++) { 
					if($view["wr_opt{$i}_price"]) { 
						$cn++;
				?>
				<tr><td width="3" height=20><center><img src="<?=$board_skin_path?>/img/bul_07.gif"></td>
					<td width="100"><?=$view["wr_opt{$i}_name"]?></td>
					<td width="2">:</td>
					<td width="200"><?=number_format($view["wr_opt{$i}_price"])?>
						<input type=hidden name=wr_opt<?=$i?>_price value='<?=$view["wr_opt{$i}_price"]?>'>
						<input type=checkbox name=chk_opt<?=$i?> value='1' onclick='add_sum()'>
					</td>
				</tr>
				<? } ?>
				<? } ?>
				<tr>
					<td width="3" height=20><center><img src="<?=$board_skin_path?>/img/bul_07.gif"></td>
					<td width="100">구매수량</td>
					<td width="2">:</td>
					<td width="200">
				
					<table cellspacing=0 cellpadding=0>
					<tr>
						<td rowspan=2><input type=text name=wr_qty class=input onchange='add_sum()' style='IME-MODE: active' value='1' size=3></td>
						<td width="10"></td>
						<td align="center"><img src='<?=$board_skin_path?>/img/up.gif' alt='증가' border=0 style='cursor:pointer;' onclick="qty_change('up');"> <img src='<?=$board_skin_path?>/img/down.gif' alt='감소' border=0 style='cursor:pointer;' onclick="qty_change('dn');"></td>
					</tr>
					</table>
				
					</td>
				</tr>
				<tr>
					<td width="3" height=20><center><img src="<?=$board_skin_path?>/img/bul_07.gif"></td>
					<td width="100">합계</td>
					<td width="2">:</td>
					<td width="200"><input type=text name=total_price_view style="border:0px solid #FFFFFF;text-align:right" value='<?=number_format($view[wr_price])?>' readonly> <input type=hidden name=wr_price value='<?=$view[wr_price]?>'> <input type=hidden name=total_price value='<?=$view[wr_price]?>'>원</td>
				</tr>
				<tr>
					<td width="3" height=20><center><img src="<?=$board_skin_path?>/img/bul_07.gif"></td>
					<td width="100">포인트적립금</td>
					<td width="2">:</td>
					<td width="200"><strong><?=$view[wr_2]?>원<strong></td>
				</tr>
				<? 
				//부가 옵션들에 대한 부분 출력	
				for($i=0; $i < 10; $i++) {
					//echo "bo_subj : ".$board["bo_{$i}_subj"]."<br>";
					$option_subj = $board["bo_{$i}_subj"];
					$option_value = $view["wr_{$i}"];

					if(trim($option_subj) == "") continue;
				?>
				<tr>
					<td width="3" height=20><center><img src="<?=$board_skin_path?>/img/bul_07.gif"></td>
					<td width="100"><?=$option_subj?></td>
					<td width="2">:</td>
					<td width="200"><?=$option_value?></td>
				</tr>
				<? } ?>
				<? if ($view[wr_4]) { ?>
				<tr>
					<td width="3" height=20><center><img src="<?=$board_skin_path?>/img/bul_07.gif"></td>
					<td width="100">옵션/기타</td>
					<td width="2">:</td>
					<td width="200"><?=$view[wr_4]?></td>
				</tr>
				<? } ?>
				<tr><td colspan=4 height=5></td></tr>
				<tr><td colspan=4 height=1 bgcolor=#e7e7e7></td></tr>
				<tr><td colspan=4 height=5></td></tr>
				<tr>
					<td colspan="4" align=right><a href="javascript:fitemcheck(document.cart, 'cart_update');"><img src='<?=$board_skin_path?>/img/scrap.gif' alt='장바구니 담기' border='0' align='absmiddle'></a>&nbsp;&nbsp;&nbsp;<a href="javascript:fitemcheck(document.cart, 'direct_buy');"><img src='<?=$board_skin_path?>/img/view_14.gif' alt='바로 구매하기' align='absmiddle'></a></td>
				</tr>
				</table>
			
				</td>
			</tr>
			</form>
			</table>
		
			</td>
		</tr>
		<tr><td height="10"></td></tr>
		</table>

		</td>
	</tr>
	</table>
	
	<table width="100%" cellspacing="0" cellpadding="0" border="0">
	<tr><td height="30"></td></tr>
	<tr>
		<td background="<?=$board_skin_path?>/img/bg_line.gif"><img src="<?=$board_skin_path?>/img/title1.gif"></td>
	</tr>
	<tr><td height="10"></td></tr>
	<tr>
		<td align="center">
		<table width="97%" cellspacing="0" cellpadding="0" border="0">
		<tr>
			<td><span class="ct lh"><?=conv_content($view[wr_content], 2);?><!-- 테러 태그 방지용 --></xml></xmp><a href=""></a><a href=''></a></td>
		</tr>
		</table>
		</td>
	</tr>
	<tr><td height="30"></td></tr>
	<tr>
		<td background="<?=$board_skin_path?>/img/bg_line.gif"><img src="<?=$board_skin_path?>/img/title2.gif"></td>
	</tr>
	<tr><td height="10"></td></tr>
	<tr>
		<td align="Center">
		<?
			if ($view[file][9][view]) {
				echo $view[file][9][view];
			} else {
				echo "약도이미지가 없습니다";
			}
		?>
		</td>
	</tr>
	<tr><td height="30"></td></tr>
	<tr>
		<td background="<?=$board_skin_path?>/img/bg_line.gif"><img src="<?=$board_skin_path?>/img/title3.gif"></td>
	</tr>
	<tr><td height="10"></td></tr>
	<tr>
		<td align="Center">
		<?
			if ($view[file][10][view]) {
				echo $view[file][10][view];
			} else {
				echo "약도이미지가 없습니다";
			}
		?>
		</td>
	</tr>
	<tr><td height="30"></td></tr>
	<tr>
		<td background="<?=$board_skin_path?>/img/bg_line.gif"><img src="<?=$board_skin_path?>/img/title4.gif"></td>
	</tr>
	<tr><td height="10"></td></tr>
	<tr>
		<td align="Center">
		<?
		include_once("./view_comment.php");
		?>
		</td>
	</tr>
	</table>

<script language="javascript">

// 바로구매 또는 장바구니 담기
function fitemcheck(f, act) 
{
    // 판매가격이 0 보다 작다면
    if (f.wr_price.value < 0) 
    {
        alert("전화로 문의해 주시면 감사하겠습니다.");
        return;
    }
	/*  옵션 데이타 사용하지 않음
    for (i=1; i<=6; i++) 
    {
        if (typeof(f.elements["it_opt"+i]) != 'undefined') 
        {
            if (f.elements["it_opt"+i].value == '선택') {
                alert(f.elements["it_opt"+i+"_subject"].value + '을(를) 선택하여 주십시오.');
                f.elements["it_opt"+i].focus();
                return;
            }
        }
    }
	*/
    if (act == "direct_buy") {
        f.sw_direct.value = 1;
    } else {
        f.sw_direct.value = 0;
    }

    if (!f.wr_qty.value) {
        alert("수량을 입력해 주십시오.");
        f.wr_qty.focus();
        return;
    } else if (isNaN(f.wr_qty.value)) {
        alert("수량을 숫자로 입력해 주십시오.");
        f.wr_qty.select();
        f.wr_qty.focus();
        return;
    } else if (parseInt(f.wr_qty.value) < 1) {
        alert("수량은 1 이상 입력해 주십시오.");
        f.wr_qty.focus();
        return;
    }

    //amount_change();
	
	f.action = "<?=$board_skin_path?>/cartupdate.php";
    f.submit();
}


function add_sum()
{
    var bf = document.cart ;
    var total_price;
    total_price = bf.wr_price.value;

    <?
    $cn++;    
    for($i=1;$i<$cn;$i++) { ?>
    if(bf.chk_opt<?=$i?>.checked==true) total_price = parseInt(total_price) + parseInt(bf.wr_opt<?=$i?>_price.value);
    <? } ?>
    
    total_price = parseInt(total_price) * parseInt(bf.wr_qty.value);     
    bf.total_price_view.value = numchk(total_price);
    bf.total_price.value = total_price;

}

function qty_change(chg)
{
    var f = document.cart ;
    var qty = f.wr_qty.value;

    if(chg=='up') qty++;                
    if(chg=='dn') qty--;

    if(qty<1) qty = 1;
    f.wr_qty.value = qty;
    add_sum();

}

function cart_submit(f)
{
    f.action = "<?=$board_skin_path?>/order.php";
    f.submit();
}


</script>

<div style="height:1px; line-height:1px; font-size:1px; background-color:#ddd; clear:both;">&nbsp;</div>

<div style="clear:both; height:43px;">
    <div style="float:left; margin-top:10px;">
    <? if ($prev_href) { echo "<a href=\"$prev_href\" title=\"$prev_wr_subject\"><img src='$board_skin_path/img/btn_prev.gif' border='0' align='absmiddle'></a>&nbsp;"; } ?>
    <? if ($next_href) { echo "<a href=\"$next_href\" title=\"$next_wr_subject\"><img src='$board_skin_path/img/btn_next.gif' border='0' align='absmiddle'></a>&nbsp;"; } ?>
    </div>

    <!-- 링크 버튼 -->
    <div style="float:right; margin-top:10px;">
    <?=$link_buttons?>
    </div>
</div>

<div style="height:2px; line-height:1px; font-size:1px; background-color:#dedede; clear:both;">&nbsp;</div>
</td></tr></table>

<script language="JavaScript">
// HTML 로 넘어온 <img ... > 태그의 폭이 테이블폭보다 크다면 테이블폭을 적용한다.
function resize_image()
{
    var target = document.getElementsByName('target_resize_image[]');
    var image_width = parseInt('<?=$board[bo_image_width]?>');
    var image_height = 0;

    for(i=0; i<target.length; i++) { 
        // 원래 사이즈를 저장해 놓는다
        target[i].tmp_width  = target[i].width;
        target[i].tmp_height = target[i].height;
        // 이미지 폭이 테이블 폭보다 크다면 테이블폭에 맞춘다
        if(target[i].width > image_width) {
            image_height = parseFloat(target[i].width / target[i].height)
            target[i].width = image_width;
            target[i].height = parseInt(image_width / image_height);
        }
    }
}

window.onload = resize_image;

function file_download(link, file)
{
<? if ($board[bo_download_point] < 0) { ?>if (confirm("'"+file+"' 파일을 다운로드 하시면 포인트가 차감(<?=number_format($board[bo_download_point])?>점)됩니다.\n\n포인트는 게시물당 한번만 차감되며 다음에 다시 다운로드 하셔도 중복하여 차감하지 않습니다.\n\n그래도 다운로드 하시겠습니까?"))<?}?>
document.location.href = link;
}
</script>
<!-- 게시글 보기 끝 -->
